<template>
  <div class="newInfo-container">
    <h2 class="title">{{ newsInfo.message }}</h2>
    <p class="subtitle">
      <span>发表时间：{{ newsInfo.m_date | dateFormatter }}</span>
      <span>点击：{{ newsInfo.click }}次</span>
    </p>
    <hr />
    <div class="contents">
      {{ newsInfo.contents }}
    </div>
    <!-- 评论组件 -->
    <comment-box :id="id"></comment-box>
  </div>
</template>

<script>
//1.导入评论子组件
import comment from '../subcomponents/comment.vue'
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo: {}
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("getNewsInfo?id=" + this.id).then(result => {
        if (result.status === 200) {
          this.newsInfo = result.body;
        } else {
          Toast("请求详情失败");
        }
      });
    }
  },
  components:{
      'comment-box':comment
  }
};
</script>

<style lang="scss" scoped>
.newInfo-container {
  padding: 0 4px;
  .title {
    font-size: 16px;
    margin: 15px 0;
    color: red;
    text-align: center;
  }
  .subtitle {
    font-size: 13px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
  .contents {
      font-size: 12px;
      color: #ccc;
  }
}
</style>
